package com.pjhouse.module.screen.user;

import javax.annotation.Resource;

import com.alibaba.citrus.turbine.Context;
import com.alibaba.citrus.turbine.TurbineRunData;
import com.alibaba.citrus.turbine.dataresolver.Param;
import com.pjhouse.core.common.domain.Result;
import com.pjhouse.core.user.domain.UserDTO;
import com.pjhouse.core.user.service.UserService;

/**
 * 修改用户信息
 * @author cangkun.zy
 *
 */
public class ModifyUser {

	@Resource
	private UserService userService;
	
	public void execute(
			@Param("id") final long id,
			TurbineRunData rundata, Context context){
		if(id <= 0){
			context.put("message", "参数错误");
			return ;
		}
		Result<UserDTO> r = userService.getById(id);
		if(r.isFailure()){
			context.put("message", r.getErrorMessage());
			return ;
		}
		UserDTO user = r.getValue();
		if(user == null){
			context.put("message", "对应账号不存在");
			return ;
		}
		context.put("u", user);
	}
}
